<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <h1><?php echo $heading_title; ?></h1>
  <div class="restaurant-info">
    <?php if ($thumb || $images) { ?>
    <div class="left">
      <?php if ($thumb) { ?>
      <div class="image"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a></div>
      <?php } ?>
      <?php if ($images) { ?>
      <div class="image-additional">
        <?php foreach ($images as $image) { ?>
        <a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
        <?php } ?>
      </div>
      <?php } ?>
    </div>
    <?php } ?>
    <div class="right">
      <div class="description">
      	<span><?php echo $text_url; ?></span> <?php echo $url; ?><br />
      	<span><?php echo $text_email; ?></span> <?php echo $email; ?><br />
      	<span><?php echo $text_phone; ?></span> <?php echo $phone; ?><br />
      	<span><?php echo $text_fax; ?></span> <?php echo $fax; ?>
      </div>
      <div class="description" style="border-top:none">
      	<?php $i = 1;?>
      	<?php foreach ($addresses as $address){?>
      	<span><?php echo $text_address . (sizeof($addresses) > 0? ' ' . $i:'');?>: </span>
      	<?php echo $address['address'] . ', ' . $address['district'] . ', ' . $address['city'] . ', ' . $address['country'] . '.';?>
      	<?php $i++;?>
      	<br/>
      	<?php }?>
      </div>
      <?php if ($options) { ?>
      	<?php foreach ($options as $option) {
        	if ($option['category'] == 'service') {
        	continue;
        	} 
       	?>
      	<div class="options">
	        <?php if ($option['type'] == 'image') { ?>
	        <div id="option-<?php echo $option['option_id']; ?>" class="option">
	          <b><?php echo $option['name']; ?>:</b><br />
	            <div id="container" style="overflow:auto; width:100%;margin-top:5px;">
	              <?php foreach ($option['option_value'] as $option_value) { ?>
	              	<div style="float:left;width:<?php echo $this->config->get('config_image_restaurant_option_width') + 10;?>px;height:40px;">
		                <a href="<?php echo $option_value['href']; ?>">
			                <img title="<?php echo $option_value['name']; ?> (<?php echo $option_value['total_restaurant']; ?>)" src="<?php echo $option_value['image']; ?>" />
		                </a>
	                </div>
	              <?php } ?>
	            </div>
	            <script type="text/javascript">
		        $('#option-<?php echo $option['option_id']; ?> img').tooltip({
		        	track: true,
		        	delay: 0,
		        	showURL: false,
		        	showBody: " - ",
		        	fade: 250
		        });
		        </script>
	        </div>
	        <?php } ?>
      	</div>
      <?php } ?>
      <div class="options">
      	<?php 
      	$total_service = 0;
      	foreach ($options as $option) { 
	        if ($option['category'] != 'service') {
	        	continue;
	        }
	        $total_service++;
	    ?>
            <div id="option-<?php echo $option['option_id']; ?>" class="option">     
            	<b><?php echo $text_service; ?>:</b><br />
            	<div id="container" style="overflow:auto; width:100%;margin-top:5px;">
	              <?php foreach ($option['option_value'] as $option_value) { ?>
	              	<div style="float:left;width:<?php echo $this->config->get('config_image_restaurant_option_width') + 10;?>px;height:40px;">
		                <a href="<?php echo $option_value['href']; ?>">
			                <img title="<?php echo $option_value['name']; ?> (<?php echo $option_value['total_restaurant']; ?>)" src="<?php echo $option_value['image']; ?>" />
		                </a>
	                </div>
	              <?php } ?>
	            </div>
		    </div>
		    <script type="text/javascript">
		    $('#option-<?php echo $option['option_id']; ?> img').tooltip({
		    	track: true,
		    	delay: 0,
		    	showURL: false,
		    	showBody: " - ",
		    	fade: 250
		    });
		    </script>
	    <?php
      	} 
      	?>
        
        <?php if($total_service == 0){
        	echo $text_no_service;
        }
        ?>
      </div>
      <?php } ?>
    </div>
    <?php if ($review_status) { ?>
    <div style="clear:both">
      <div class="review">
        <div><img src="portal/view/theme/default/image/stars-<?php echo $rating; ?>.png" alt="<?php echo $reviews; ?>" />&nbsp;&nbsp;<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $reviews; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('a[href=\'#tab-review\']').trigger('click');"><?php echo $text_write; ?></a></div>
        <div class="share"><!-- AddThis Button BEGIN -->
          <div class="addthis_default_style"><a class="addthis_button_compact"><?php echo $text_share; ?></a> <a class="addthis_button_email"></a><a class="addthis_button_print"></a> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a></div>
          <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script> 
          <!-- AddThis Button END --> 
        </div>
      </div>
      <div class="cart" style="border-bottom:none">
        <div>
          <img src="portal/view/theme/default/image/favorite.png" style="vertical-align:middle"/> <a onclick="addToWishList('<?php echo $restaurant_id; ?>', '<?php echo urlencode($redirect);?>');"><?php echo $button_wishlist; ?></a><br />
        </div>
        <div style="clear:both; margin-top: 5px">
          <img src="portal/view/theme/default/image/booking.png" style="vertical-align:middle"/> <a href="<?php echo $booking;?>" class="fancybox" id="booking"><?php echo $button_booking; ?></a><br />
        </div>
      </div>
    </div>
    <?php } ?>    
  </div>
  <div id="tabs" class="htabs">
  	<a href="#tab-description"><?php echo $tab_description; ?></a>
  	<a href="#tab-map"><?php echo $tab_map; ?></a>
    <?php if ($review_status) { ?>
    <a href="#tab-review"><?php echo $tab_review; ?></a>
    <?php } ?>
  </div>
  <div id="tab-description" class="tab-content"><?php echo $description; ?></div>
  <?php if ($review_status) { ?>
  <div id="tab-review" class="tab-content">
    <div id="review">
    	
    </div>
    <h2 id="review-title"><?php echo $text_write; ?></h2>
    <b><?php echo $entry_name; ?></b><br />
    <input type="text" name="name" value="" />
    <br />
    <br />
    <b><?php echo $entry_review; ?></b>
    <textarea name="text" cols="40" rows="8" style="width: 98%;"></textarea>
    <span style="font-size: 11px;"><?php echo $text_note; ?></span><br />
    <br />
    <b><?php echo $entry_rating; ?></b> <span><?php echo $entry_bad; ?></span>&nbsp;
    <input type="radio" name="rating" value="1" />
    &nbsp;
    <input type="radio" name="rating" value="2" />
    &nbsp;
    <input type="radio" name="rating" value="3" />
    &nbsp;
    <input type="radio" name="rating" value="4" />
    &nbsp;
    <input type="radio" name="rating" value="5" />
    &nbsp; <span><?php echo $entry_good; ?></span><br />
    <br />
    <b><?php echo $entry_captcha; ?></b><br />
    <input type="text" name="captcha" value="" />
    <br />
    <img src="index.php?route=restaurant/restaurant/captcha" alt="" id="captcha" /><br />
    <br />
    <div class="buttons">
      <div class="right"><a id="button-review" class="button"><span><?php echo $button_continue; ?></span></a></div>
    </div>
  </div>
  <?php } ?>
  <div id="tab-map" class="tab-content" style="text-align:center">
  	<?php $i = 1;?>
    <?php foreach ($addresses as $address){?>
	    <div style="text-align: left; margin-top: 20px; clear:both">
	    <span style="font-weight: bold"><?php echo $text_address . (sizeof($addresses) > 0? ' ' . $i:'');?>: <?php echo $address['address'] . ', ' . $address['district'] . ', ' . $address['city'] . ', ' . $address['country'] . '.';?></span>
	    <img src="http://maps.googleapis.com/maps/api/staticmap?markers=color:blue%7Clabel:M%7C<?php echo urlencode($address['address']) . "," . urlencode($address['district']) . "," . urlencode($address['city']) . "," . urlencode($address['country']); ?>&zoom=16&size=760x500&sensor=false"/>
	    <?php $i++;?>
		</div>
    <?php }?>
  </div>
  <?php if ($tags) { ?>
  <div class="tags"><b><?php echo $text_tags; ?></b>
    <?php foreach ($tags as $tag) { ?>
    <a href="<?php echo $tag['href']; ?>"><?php echo $tag['tag']; ?></a>,
    <?php } ?>
  </div>
  <?php } ?>
  <?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
$('.fancybox').fancybox();
//--></script> 
<script type="text/javascript"><!--
$('#button-cart').bind('click', function() {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: $('.restaurant-info input[type=\'text\'], .restaurant-info input[type=\'hidden\'], .restaurant-info input[type=\'radio\']:checked, .restaurant-info input[type=\'checkbox\']:checked, .restaurant-info select, .restaurant-info textarea'),
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, information, .error').remove();
			
			if (json['error']) {
				if (json['error']['warning']) {
					$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="portal/view/theme/default/image/close.png" alt="" class="close" /></div>');
				
					$('.warning').fadeIn('slow');
				}
				
				for (i in json['error']) {
					$('#option-' + i).after('<span class="error">' + json['error'][i] + '</span>');
				}
			}	 
						
			if (json['success']) {
				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="portal/view/theme/default/image/close.png" alt="" class="close" /></div>');
					
				$('.success').fadeIn('slow');
					
				$('#cart_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
});
//--></script>
<?php if ($options) { ?>
<script type="text/javascript" src="portal/view/javascript/jquery/ajaxupload.js"></script>
<?php foreach ($options as $option) { ?>
<?php if ($option['type'] == 'file') { ?>
<script type="text/javascript"><!--
new AjaxUpload('#button-option-<?php echo $option['option_id']; ?>', {
	action: 'index.php?route=restaurant/restaurant/upload',
	name: 'file',
	autoSubmit: true,
	responseType: 'json',
	onSubmit: function(file, extension) {
		$('#button-option-<?php echo $option['option_id']; ?>').after('<img src="portal/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
	},
	onComplete: function(file, json) {
		$('.error').remove();
		
		if (json.success) {
			alert(json.success);
			
			$('input[name=\'option[<?php echo $option['option_id']; ?>]\']').attr('value', json.file);
		}
		
		if (json.error) {
			$('#option-<?php echo $option['option_id']; ?>').after('<span class="error">' + json.error + '</span>');
		}
		
		$('.loading').remove();	
	}
});
//--></script>
<?php } ?>
<?php } ?>
<?php } ?>
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').slideUp('slow');
		
	$('#review').load(this.href);
	
	$('#review').slideDown('slow');
	
	return false;
});			

$('#review').load('index.php?route=restaurant/restaurant/review&restaurant_id=<?php echo $restaurant_id; ?>');

$('#button-review').bind('click', function() {
	$.ajax({
		type: 'POST',
		url: 'index.php?route=restaurant/restaurant/write&restaurant_id=<?php echo $restaurant_id; ?>',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-review').attr('disabled', true);
			$('#review-title').after('<div class="attention"><img src="portal/view/theme/default/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#button-review').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review-title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review-title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=\'name\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
});
//--></script> 
<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<script type="text/javascript" src="portal/view/javascript/jquery/ui/jquery-ui-timepicker-addon.js"></script> 
<script type="text/javascript"><!--
if ($.browser.msie && $.browser.version == 6) {
	$('.date, .datetime, .time').bgIframe();
}

$('.date').datepicker({dateFormat: 'yy-mm-dd'});
$('.datetime').datetimepicker({
	dateFormat: 'yy-mm-dd',
	timeFormat: 'h:m'
});
$('.time').timepicker({timeFormat: 'h:m'});
//--></script> 
<?php echo $footer; ?>